package com.net.xpay.partner.controller.partner;

import com.net.common.model.ResultPagedList;
import com.net.xpay.common.domain.partner.Partner;
import com.net.xpay.common.domain.sync.CommonChargeRecord;
import com.net.xpay.common.manager.sync.CommonChargeRecordManager;
import com.net.xpay.core.model.ChargeRecordSearchModel;
import com.net.xpay.partner.secutiry.RequestUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 *

 * 读取从commonChargeRecord中读，commonChargeRecord是分库聚合表
 */
@RestController
@RequestMapping("/partner/charge-record")
@Api(tags = "运营/商户充值", description = "运营 商户充值 net")
public class PartnerChargeRecordController {

    @Autowired
    private CommonChargeRecordManager commonChargeRecordManager;

    @ApiOperation("搜索充值记录")
    @PostMapping("/search")
    @ResponseBody
    public ResultPagedList<CommonChargeRecord> searchChargeRecord(@ApiIgnore @RequestUser Partner partner, @RequestBody ChargeRecordSearchModel searchModel) {
        searchModel.setPartnerId(partner.getId());
        List<CommonChargeRecord> records = commonChargeRecordManager.search(searchModel);
        long count = commonChargeRecordManager.searchCount(searchModel);

        return new ResultPagedList<>(records, count, searchModel);
    }
}
